#!/bin/bash

echo "========================================"
echo "火车订票系统 - 测试运行脚本"
echo "========================================"
echo

echo "正在清理之前的测试结果..."
rm -rf target/surefire-reports
rm -rf target/test-classes

echo
echo "正在运行单元测试..."
mvn test -Dspring.profiles.active=test

echo
echo "正在生成测试报告..."
mvn surefire-report:report

echo
echo "测试完成！"
echo "测试报告位置: target/site/surefire-report.html"
echo

# 检查测试是否成功
if [ $? -eq 0 ]; then
    echo "✅ 所有测试通过！"
else
    echo "❌ 测试失败，请检查错误信息"
    exit 1
fi
